package com.example.lazyhelper;

import android.os.Bundle;

import com.google.android.material.bottomnavigation.BottomNavigationView;

import androidx.appcompat.app.AppCompatActivity;
import androidx.navigation.NavController;
import androidx.navigation.Navigation;
import androidx.navigation.ui.AppBarConfiguration;
import androidx.navigation.ui.NavigationUI;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // 加载主活动的布局文件
        setContentView(R.layout.activity_main);
        // 找到底部导航栏组件
        BottomNavigationView navView = findViewById(R.id.nav_view);
        // 注册导航栏对应页面
        AppBarConfiguration appBarConfiguration = new AppBarConfiguration.Builder(
                R.id.navigation_request, R.id.navigation_offer, R.id.navigation_profile)
                .build();
        // 设置Fragment容器
        NavController navController = Navigation.findNavController(this, R.id.nav_host_fragment);

        // 绑定导航栏和Fragment容器
        NavigationUI.setupActionBarWithNavController(this, navController, appBarConfiguration);
        NavigationUI.setupWithNavController(navView, navController);
    }

}